import { http } from '@/utils/http'
import type { AddressItem, AddressParams } from '@/types/address'
/**
 * 新增收货地址
 */
export const postMemberAddressAPI = (data) => {
  return http<AddressParams>({
    method: 'POST',
    url: '/member/address',
    data,
  })
}
/**
 * 获取所有收货地址的接口
 */
export const getMemberAddressAPI = () => {
  return http<AddressItem[]>({
    method: 'GET',
    url: '/member/address',
  })
}
/**
 *根据id获取一个地址
 */
export const getMemberAddressByIdAPI = (id: string) => {
  return http<AddressItem>({
    method: 'GET',
    url: `/member/address/${id}`,
  })
}
/**
 * 修改收货地址
 */
export const putMemberAddressById = (id: string, data: AddressParams) => {
  return http({
    method: 'PUT',
    url: `/member/address/${id}`,
    data,
  })
}
/**
 *根据id删除一个地址
 */
export const deleteMemberAddressByIdAPI = (id: string) => {
  return http({
    method: 'DELETE',
    url: `/member/address/${id}`,
  })
}
